package helperclasses;

import java.util.Vector;

import interfaces.ILogging;

/**
 * Simple thread-safe logging class, which is able to print out all passed log-entries
 * 
 * @author tim
 * @version 0.4.1
 * @since 0.4.1
 */
public class Logger implements ILogging {

	Vector<String> entrys;
	
	public Logger()
	{
		this.entrys = new Vector<String>();
	}
	
	/**
	 * @param classname Name of the class which passed this entry
	 * @param message The Messagetext
	 */
	@Override
	public void addEntry(String classname, String message) {
		entrys.add(classname+": "+message);
	}

	/**
	 * This method prints out all saved log-entries and deletes them afterwards
	 */
	@Override
	public void printAll() {
		for(String s: entrys)
		{
			System.out.println(s);
		}
		
		
		entrys.clear();
		
	}

	/**
	 * This method prints out the last added log-entry, but does not change the log
	 */
	@Override
	public void printLast() {
		System.out.println(entrys.lastElement());
	}

}
